new Vue({
   el:'#app',
        data:{
            tableData: [], //所有案件
            Case_law: {
               caseId:'',
               clientId:{
                   clientName:''
               },
               caseTypeid:{
                   caseTypeid:''
               }
            },
            case_type:[],  //所有类型
            type_key:{
               value:'caseTypeid',
               label:'typeName',
               children:'children'
            },
            selectcaseTypeid: [], //选择的类型 两个参数
            handleKey:'',//操作绑定的值
            dialogVisible: false, //是否打开单条案件模态框
            law:{			//模态框显示的案件详情信息
                caseId:'',
                clientId:{
                    cname:'',
                },
                oppositeId:{
                    cname:'',
                },
                locusStandi:'',
                causeOfAction:'',
                causeDetails:'',
                caseStatus:'',
                objectOfAction:'',
                caseTypeid:{
                    typeName:''
                },
                recordFilename:'',
                submitId:{
                    user_name:''
                },
                submitDate:'',
                mainLawyer:{
                    empName:''
                },
                agencyMoney:'',
                blendMoney:'',
                amountMoney:'',
                courtId:{
                    courtName:''
                },
                sessionDate:'',
                stateSessionDate:'',
                trialDate:'',
                closeState:'',
                closeMode:'',
                closeDate:'',
                closeDate:''
            },
            //案件详情加载动画，true开启，false关闭  
            law_loding:true
        } , 
        created(){
            this.init();
        },
        methods:{
            init(){
                const loading =this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                //初始化查询
                this.$http.post("http://localhost:8080/law/selectCaseBystatus",
                    {emulateJSON:true}).then(result=>{
                    var msg = eval("("+result.body+")");
                    this.tableData = msg.data;   
                });
                this.$http.post("http://localhost:8080/case_type/queryAll",
                    {emulateJSON:true}).then(result=>{
                    var msg = eval("("+result.body+")");
                    this.case_type = msg.data;
                });
                loading.close();
            },
            queryByid(caseid){ //跳转到这个案件的详细信息页面
                //打开模态框
                this.dialogVisible = true;
                //得到选择的案件id
                this.$http.post("http://localhost:8080/law/queryByid",
                    {"caseid":caseid},
                    {emulateJSON:true}).then(result=>{
                    var msg = eval("("+result.body+")");
                    this.law = msg.data;
                });
                //将加载动画关闭
                this.law_loding =false;
            },
            onSubmit() {
                //得到模糊查询选择的所有的值
                var typeid = this.selectcaseTypeid[1];
                if(typeid == undefined){
                    typeid=-1
                }
                this.Case_law.caseTypeid.caseTypeid = typeid;
                var data = JSON.stringify(this.Case_law);
                this.$http.post("http://localhost:8080/law/selectCaseBystatus",
                    {"data":data},
                    {emulateJSON:true}).then(result=>{
                    var msg = eval("("+result.body+")");
                    this.tableData = msg.data;
                });
            },
            handleClose(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {});
            }
            
        }
});